﻿<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <title>药库管理系统登录页面 </title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.min.css">
    <link rel="stylesheet" href="css/dmaku.css">
</head>
<body>
    <div class="dowebok" id="dowebok">
        <div class="form-container sign-up-container">
            <el-card class="box-card">
                <h1>注册</h1>
                <input type="text" placeholder="用户名" v-model="user.username">
                <input type="password" placeholder="密码" v-model="user.password">
                <input type="text" placeholder="资格证书编号" v-model="user.certificationkey">
                <input type="text" placeholder="职称" v-model="user.number">
                <input type="text" placeholder="验证码" v-model="user.verify">
                <input type="button" value="注册" @click="reg()">
            </el-card>
        </div>
        <div class="form-container sign-in-container">
            <el-card class="box-card">
                <div  class="text item">
                    <h1>登录</h1>
                    <input type="text" placeholder="用户名" v-model="user.username">
                    <input type="password" placeholder="密码" v-model="user.password">
                    <a href="#">忘记密码？</a>
                    <input type="button" value="登录" @click="login()">
                </div>
            </el-card>
        </div>
        <div class="overlay-container">
            <div class="overlay">
                <div class="overlay-panel overlay-left">
                    <h1>已有帐号？</h1>
                    <p>请使用您的帐号进行登录</p>
                    <button class="ghost" id="signIn">登录</button>
                </div>
                <div class="overlay-panel overlay-right">
                    <h1>没有帐号？</h1>
                    <p>立即注册加入我们，和我们一起开始旅程吧</p>
                    <button class="ghost" id="signUp" @click="switchTo()">注册</button>
                </div>
            </div>
        </div>
    </div>

</body>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<!-- import Vue before Element -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<script src="js/dmaku.js"></script>
<script>
    let v = new Vue({
        el: 'body>div',
        data: function() {
            return {
                user:{username:"",password:"",certificationkey:"",number:"",verify:""}
            }
        },
        methods:{
            reg(){
                axios.post("/reg",v.user).then(function (response){
                    if (response.data==1){
                        alert("注册成功");
                        location.href="/";
                    }else {
                        alert("用户名已存在");
                    }
                })
            },
            login(){
                axios.post("/login",v.user).then(function (response){
                    if (response.data==1){
                        alert("登录成功");
                        location.href="/";
                    }else if(response.data==2){
                        alert("用户名不存在");
                    }else {
                        alert("密码错误");
                    }
                })
            },
            switchTo(){
                var signUpButton = document.getElementById('signUp')
                var signInButton = document.getElementById('signIn')
                var container = document.getElementById('dowebok')

                signUpButton.addEventListener('click', function () {
                    container.classList.add('right-panel-active')
                })

                signInButton.addEventListener('click', function () {
                    container.classList.remove('right-panel-active')
                });
            }

        },

    })
</script>
</html>